Skip to content

Merge imported job outputs with main workflow precedence - #72407

Merged
pelikhan merged 4 commits into
mainfrom
pelikhan/ideal-garbanzo
Oct 27, 2026
Merged

pelikhan merged 4 commits into
mainfrom
pelikhan/ideal-garbanzo

Conversation

@pelikhan

@pelikhan pelikhan commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Imported workflows can contribute job output mappings, but same-named job definitions previously dropped outputs instead of combining them. This lets shared agentic workflows expose outputs alongside those defined in the main workflow.

Changes

  • Merge jobs.<job-id>.outputs by name across imports and the main workflow. Main workflow values always win, including explicit empty strings; later-discovered imports win conflicts between imported output names.
  • Preserve input maps, existing injected-step ordering, and job-definition precedence. Output-only contributions retain the earlier complete body even when injected steps are present.
  • Treat absent and null output collections as empty mappings during merging while preserving non-map handling and existing schema validation.
  • Reject final output expressions referencing regular steps discarded by job-body selection, after applying main-workflow overrides. Retained regular or injected producers remain valid.
  • Document the selection rules and add unit and compilation regressions for precedence, null collections, body preservation, discarded producers, and input immutability.

ADR: ADR-72407: Merge Imported Job Outputs by Name with Main Workflow Precedence

Validation

  • Targeted output-merging, compilation, discarded-producer rejection, and agent continue-on-error regression tests pass.
  • Formatting, Go lint, custom linters, schema freshness, and impacted unit checks pass.
  • Workflow drift check passes: all 349 workflows compile with no lock-file changes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review October 27, 2026 10:52
Copilot AI max review requested due to automatic review settings October 27, 2026 10:52
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Commit pushed: 30df2d2

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · haiku45 · ~7 AIC · ⌖ ~9 AIC · ◇ ~3 AIC · ⊞ 8.8K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Ponytail Reviewer · gpt56 · ~12 AIC · ⌖ ~6 AIC · ⊞ 14.8K · ◷

Generated by Ponytail Reviewer for #72407

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-10-27T10:56:08Z
review_event: COMMENT
top_themes: [null outputs silently drop imported mappings]
files_reviewed: [docs/src/content/docs/reference/imports.md, pkg/workflow/workflow_import_merge.go, pkg/workflow/workflow_import_merge_test.go]
comment_count: 1

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: comment

One correctness edge case needs attention: a null/empty outputs: declaration silently prevents imported outputs from being merged, contrary to the documented union behavior. I left an inline comment with the suggested fix and regression test.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again

Comment thread pkg/workflow/workflow_import_merge.go Resolved
@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (239 new lines under pkg/) but does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/72407-merge-imported-job-outputs-with-main-precedence.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

Decision captured in the draft: when an import and the main workflow define the same job, jobs.<job-id>.outputs are merged by name. The main workflow wins conflicts, and among imports the later-discovered import wins. Other job fields keep their existing precedence rules. The draft also lists the alternatives considered: keeping the current main-wins-outright behavior, failing the compile on output-name conflicts, and deep-merging whole jobs.

📋 What to do next
  1. Review the draft ADR committed to your branch. It was generated from the PR diff.
  2. Complete the missing sections: resolve the [TODO: verify] markers (deciders, and whether non-map outputs values are validated elsewhere), refine the rationale, and confirm the alternatives.
  3. Commit the finalized ADR to docs/adr/ on your branch.
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-72407: Merge Imported Job Outputs by Name with Main Workflow Precedence

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

❓ Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say 'I'll deal with this later.' Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context: What is the problem? What forces are at play?
  • Decision: What did you decide? Why?
  • Alternatives Considered: What else could have been done?
  • Consequences: What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · opus55 · ~26 AIC · ⌖ ~42 AIC · ⊞ 1.9K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd — found one reproducible field-loss bug in the new job-merge path; everything else (naming, docs, existing tests) looks solid.

📋 Key Themes & Highlights

Key Themes

  • Silent field loss: In accumulateImportedJobs (and the mirrored mergeJobImportFields), when two job definitions both need merging (outputs + a plain scalar/map field like runs-on or env) but only one side triggers a step-merge, the branch clones whichever job "won" the step-merge decision rather than the later import. Any field unique to the "losing" side that isn't outputs/setup-steps/pre-steps/continue-on-error is silently dropped. Reproduced directly against the new code (see inline comment) — this is a real data-loss bug, not a style nit.
  • Test coverage gap: The new TestMergeJobsFromYAMLImports_Outputs* suite is thorough for the outputs dimension, but no case combines outputs with a conflicting non-step scalar field (e.g. runs-on, env), which is exactly the combination that triggers the bug.

Positive Highlights

  • ✅ Clear separation of concerns: mergeJobOutputField is a small, well-named pure function with sensible precedence (main wins, including explicit empty string; later import wins among imports).
  • ✅ Mutation-safety is explicitly tested (TestMergeJobImportFields_OutputsDoNotMutateInputs), exactly the regression-prevention /tdd encourages.
  • ✅ Docs (imports.md) were updated in the same PR to describe the new merge semantics — good /grill-with-docs hygiene.
  • ✅ End-to-end compilation test (TestImportedJobOutputsCompile) validates the lock-file output, not just the in-memory merge.

Recommend fixing the field-loss path (always base the merge on a full clone of one side with the other's fields layered in, regardless of which sub-merge fired) and adding a regression test with a non-step/non-output field present only on the "losing" side.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · ~83 AIC · ⌖ ~16 AIC · ⊞ 10.2K
Comment /matt to run again

Comment thread pkg/workflow/workflow_import_merge.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Conflicting imports can produce jobs whose retained definitions and output mappings no longer match.

2 open issues
What changed in this PR

This PR extends gh-aw’s workflow import compiler so shared workflows can contribute job outputs alongside those defined in the main workflow.

Changes:

  • Merge output mappings by name, with main-workflow values taking precedence.
  • Add unit and compilation regressions for precedence, step ordering, and input immutability.
  • Document job import support and output-merging rules.
File Description
pkg/​workflow/​workflow_import_merge.go Adds output merging to job import accumulation.
pkg/​workflow/​workflow_import_merge_test.go Tests output merging and compiled workflow behavior.
docs/​src/​content/​docs/​reference/​imports.md Documents supported job imports and merge precedence.

Review effort: Max

Comment thread pkg/workflow/workflow_import_merge.go Resolved
Comment thread pkg/workflow/workflow_import_merge.go Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

Reviewed and completed the generated ADR, including output precedence, alternatives, consequences, and validation boundaries. The PR body now links it; the record remains Proposed pending PR acceptance rather than claiming reviewer approval.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

No change is required by this status report because it contains no actionable finding. The null-output fix has separate regression coverage; the reported_no_action outcome is not being treated as proof of validation or publication.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

Accepted the associated correctness finding and fixed null output collections to merge as empty mappings. Focused regression tests cover null and empty declarations without weakening non-map handling.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

No change is required by this review-in-progress notification because it contains no implementation feedback. It is not being treated as an approval or completed review.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

No change is required by this reported_no_action status because it contains no actionable finding. Validation and publication are checked independently rather than inferred from the reviewer run completing.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

Accepted and addressed the recorded null-output finding with a merge fix and regression tests. The managed comment-memory block and metadata were left unchanged.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

Completed the ADR, removed verification TODOs, documented the actual Markdown and YAML validation boundaries, and linked the record in the PR body. It records the user-directed main-workflow precedence and remains Proposed until the PR is accepted.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

The skills-based review is now complete, and its field-selection feedback was evaluated with the related inline findings. Output-only body preservation is fixed and covered by regressions; the documented non-output precedence is retained rather than changing all imports to later-body-wins.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

The ADR remains complete and linked. It now also documents output-only body preservation and compile-time rejection of references to discarded regular steps.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

The earlier disposition remains valid: the status report requests no code change. The new merge-correctness findings are handled separately with focused regressions.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

The null-output fix remains in place. The follow-up merge changes retain its regression coverage and non-map handling.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

This earlier response described the status at that time; the skills-based review has since completed. Its actionable field-selection feedback is addressed in the inline thread and follow-up regressions.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

No additional change is requested by this earlier response. The no-action reviewer status is still not being used as evidence that validation or publication succeeded.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

The recorded null-output issue remains fixed, and the managed comment-memory metadata remains unchanged. This response introduces no additional implementation requirement.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to #72407 (comment):

The ADR still records main-workflow output precedence and remains Proposed pending acceptance. It has been updated to capture the follow-up body-preservation fix and discarded-step validation.

@pelikhan
pelikhan merged commit 525d42c into main Oct 27, 2026
92 checks passed
@pelikhan
pelikhan deleted the pelikhan/ideal-garbanzo branch October 27, 2026 11:50
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants